<<<<<<< HEAD
import { message,notification } from 'antd'
import { CheckOutlined, CloseOutlined } from '@ant-design/icons';
import React from 'react'
import { auth } from '../../../utils/cloudbase'
import {connect} from 'react-redux'
import { login, logout } from '../../../redux/actions/userState';
import './index.css'
function Login(props){
    let loginEmail,loginPassword
    // 登录成功的消息提示
    const openLoginSuccess = () => {
        notification.open({
            message: '登录成功！',
            description: '欢迎使用 TodoList',
            duration: 2,
            placement: 'bottomLeft',
            icon: <CheckOutlined />,
        });
    }

    // 打开邮箱登录失败的消息提醒框
    const openEmailLoginFailed = () => {
        notification.open({
            message: '邮箱登陆失败！',
            description: '请检查邮箱地址、密码是否正确！',
            duration: 3,
            icon: <CloseOutlined />,
        });
    };
    const onEnter=e=>{
        if(e.keyCode==13){
            login()
        }
    };
    const login=async ()=>{
       if(loginPassword.value===''){
           message.warning('请输入密码！')
           return
       }
       await auth.signInWithEmailAndPassword(loginEmail.value,loginPassword.value).then(()=>{
             props.login(),
             props.history.replace('/home')
             openLoginSuccess()
       }).catch(()=>{
           props.logout()
        openEmailLoginFailed()
        loginPassword.value=''
       })
    }
    return(
        <div className="loginBox">d
            <input className="loginInput" ref={c=>loginEmail=c} type="text" placeholder="请输入邮箱地址"></input>   
            <input className="loginInput" ref={c=>loginPassword=c} type="password" onKeyUp={onEnter}  placeholder="请输入密码"></input>
            <div className="loginBtn" onClick={login}>
                    登录
            </div>
   
        </div>
    )
}
export default connect(
    state=>({}),
    {login,logout}
)(Login) 
=======
import React from 'react'
function Login(){
    return(
        <div>登录</div>
    )
}
export default Login
>>>>>>> 736eaa2195c1b7bca646cbfe9c94a3bf4562f62a
